package com.zxa.simplefactory;

/**
 * @author 赵希奥
 * @date 2022/3/3 9:24
 * @gitHub https://github.com/CKXGZXA
 * @gitee https://gitee.com/ckxgzxa
 * @description:
 */
public class FruitFactory {
    public static Fruit getFruit(String type) {
        Fruit fruit = null;
        if ("apple".equalsIgnoreCase(type)) {
            fruit = new Apple();
            System.out.println("生产苹果对象!");
        } else if ("Banana".equalsIgnoreCase(type)) {
            fruit = new Banana();
            System.out.println("生产香蕉对象!");
        } else if ("Orange".equalsIgnoreCase(type)) {
            fruit = new Orange();
            System.out.println("生产橘子对象!");
        } else {
            System.out.println("无法生产这种水果");
        }
        return fruit;
    }
}
